<?php
/**
 * Created by PhpStorm.
 * User: My
 * Date: 2019/3/27
 * Time: 13:18
 */

namespace App\Http\Helper;

use TestingPartRecordService;
use TestingPartService;
use TestingConfig;

class ParamParseHelper
{
    const PARAM_UID = '{{uid}}';
    const PARAM_TID = '{{tid}}';

    /**
     * 需要替换的参数
     * @var array
     */
    public static $replace = [
        'tid' => self::PARAM_TID,
        'uid' => self::PARAM_UID
    ];

    /**
     * 参数替换
     * @param $uri
     * @param $uid
     * @param $tid
     * @return mixed
     */
    public static function parse($uri, $uid, $tid) {
        foreach (static::$replace as $key => $value) {
            if (is_numeric(strpos($uri, $value))) {
                $uri = str_replace($value, $$key, $uri);
            }
        }
        return $uri;
    }
}